package com.yxjme.egcviewlibrary.manager;

import android.hardware.Camera;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import com.yxjme.egcviewlibrary.util.ImageProcessing;
import com.yxjme.egcviewlibrary.util.StringToAscii;

import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;


public class CameraHeartManager {

    private static final AtomicBoolean processing = new AtomicBoolean(false);

//    public static String dataSource = "[2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103,2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103,2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103,2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103,2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103,2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103,2071, 2086, 2099, 2109, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145, 2147, 2148, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 2116, 2107, 2098, 2088, 2078, 2067, 2058, 2049, 1997, 1991, 1991, 1997, 2058, 2168, 2221, 2221, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2174, 2184, 2190, 2190, 2181, 2166, 2146, 2125, 2103, 2082, 2062, 2046, 2036, 2030, 2027, 2025, 2024, 2022, 2019, 2017, 2014, 2012, 2012, 2014, 2016, 2019, 2021, 2026, 2031, 2037, 2041, 2044, 2045, 2047, 2048, 2048, 2047, 2046, 2044, 2043, 2041, 2040, 2039, 2038, 2037, 2037, 2037, 2038, 2039, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2048, 2047, 2047, 2047, 2047, 2047, 2048, 2050, 2052, 2055, 2058, 2060, 2062, 2062, 2059, 2056, 2052, 2049, 2046, 2044, 2041, 2042, 2044, 2046, 2047, 2034, 2023, 2023, 2045, 2128, 2231, 2273, 2273, 2206, 2092, 2045, 2045, 2046, 2051, 2051, 2051, 2055, 2058, 2062, 2063, 2063, 2065, 2068, 2072, 2074, 2076, 2077, 2078, 2082, 2087, 2091, 2095, 2099, 2104, 2111, 2119, 2126, 2132, 2138, 2144, 2153, 2161, 2168, 2173, 2177, 2180, 2179, 2174, 2162, 2146, 2129, 2111, 2094, 2079, 2066, 2057, 2050, 2047, 2046, 2045, 2044, 2043, 2043, 2043, 2043, 2043, 2041, 2039, 2036, 2032, 2029, 2027, 2026, 2027, 2028, 2030, 2032, 2035, 2038, 2040, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2040, 2039, 2039, 2039, 2040, 2041, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2051, 2049, 2047, 2044, 2042, 2042, 2042, 2044, 2046, 2049, 2052, 2056, 2058, 2058, 2057, 2055, 2053, 2050, 2049, 2047, 2046, 2044, 2043, 2042, 2042, 2042, 2031, 2021, 2021, 2056, 2155, 2220, 2220, 2212, 2138, 2052, 2031, 2031, 2039, 2048, 2048, 2048, 2048, 2048, 2048, 2052, 2060, 2064, 2067, 2069, 2071, 2074, 2078, 2080, 2085, 2089, 2093, 2098, 2105, 2112, 2117, 2123, 2129, 2137, 2148, 2159, 2169, 2178, 2187, 2194, 2199, 2201, 2198, 2190, 2177, 2161, 2141, 2120, 2100, 2080, 2064, 2049, 2038, 2030, 2026, 2025, 2024, 2024, 2022, 2021, 2020, 2019, 2019, 2019, 2019, 2018, 2017, 2016, 2016, 2016, 2017, 2018, 2019, 2021, 2022, 2022, 2022, 2020, 2018, 2018, 2017, 2016, 2016, 2016, 2016, 2016, 2017, 2016, 2016, 2018, 2021, 2025, 2031, 2036, 2041, 2044, 2047, 2050, 2051, 2050, 2047, 2045, 2043, 2041, 2041, 2041, 2041, 2043, 2045, 2046, 2048, 2049, 2051, 2051, 2052, 2051, 2051, 2050, 2049, 2047, 2046, 2045, 2044, 2044, 2044, 2037, 2029, 2029, 2041, 2113, 2235, 2296, 2296, 2226, 2099, 2041, 2041, 2046, 2050, 2051, 2050, 2049, 2049, 2053, 2062, 2072, 2076, 2079, 2082, 2084, 2087, 2089, 2091, 2095, 2098, 2100, 2103, 2105, 2108, 2111, 2115, 2122, 2130, 2139, 2148, 2159, 2170, 2181, 2189, 2194, 2195, 2192, 2185, 2174, 2159, 2143, 2126, 2108, 2091, 2076, 2065, 2056, 2049, 2045, 2042, 2040, 2041, 2042, 2043, 2042, 2041, 2040, 2040, 2040, 2040, 2041, 2042, 2044, 2045, 2046, 2046, 2045, 2043, 2042, 2041, 2040, 2040, 2043, 2045, 2047, 2048, 2048, 2047, 2047, 2046, 2045, 2044, 2044, 2045, 2048, 2049, 2049, 2049, 2048, 2048, 2048, 2047, 2045, 2045, 2046, 2047, 2048, 2047, 2045, 2043, 2042, 2042, 2044, 2045, 2047, 2050, 2054, 2057, 2060, 2060, 2059, 2058, 2056, 2053, 2049, 2045, 2042, 2039, 2038, 2037, 2036, 2022, 2008, 2008, 2031, 2118, 2227, 2272, 2272, 2202, 2078, 2022, 2022, 2032, 2041, 2041, 2040, 2040, 2045, 2053, 2058, 2059, 2059, 2059, 2060, 2062, 2064, 2066, 2069, 2072, 2076, 2081, 2086, 2092, 2097, 2103, 2108, 2114, 2122, 2132, 2142, 2152, 2162, 2173, 2184, 2192, 2197, 2195, 2189, 2179, 2166, 2149, 2131, 2111, 2091, 2074, 2060, 2050, 2042, 2035, 2032, 2031, 2032, 2033, 2033, 2033, 2034, 2034, 2034, 2033, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2041, 2042, 2043, 2043, 2043, 2043, 2042, 2042, 2041, 2041, 2042, 2042, 2042, 2043, 2044, 2044, 2043, 2043, 2043, 2043, 2044, 2044, 2046, 2047, 2048, 2048, 2048, 2048, 2048, 2047, 2047, 2047, 2048, 2049, 2050, 2051, 2050, 2050, 2050, 2051, 2051, 2050, 2049, 2049, 2049, 2049, 2048, 2041, 2040, 2040, 2095, 2213, 2277, 2277, 2222, 2110, 2040, 2028, 2028, 2034, 2041, 2045, 2045, 2045, 2045, 2056, 2075, 2086, 2087, 2088, 2088, 2088, 2089, 2090, 2092, 2094, 2097, 2100, 2103, 2107, 2112, 2118, 2125, 2132, 2140, 2148, 2157, 2167, 2176, 2184, 2188, 2190, 2189, 2185, 2175, 2162, 2146, 2128, 2110, 2092, 2076, 2062, 2050, 2040, 2034, 2029, 2027, 2025, 2025, 2025, 2025, 2027, 2029, 2030, 2032, 2033, 2035, 2036, 2038, 2039, 2040, 2041, 2040, 2040, 2039, 2038, 2039, 2040, 2042, 2043, 2046, 2049, 2051, 2053, 2052, 2051, 2049, 2047, 2046, 2044, 2044, 2044, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2045, 2045, 2045, 2045, 2045, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2047, 2050, 2052, 2055, 2056, 2057, 2055, 2053, 2051, 2048, 2046, 2044, 2043, 2044, 2046, 2048, 2035, 2018, 2018, 2032, 2116, 2239, 2292, 2292, 2221, 2095, 2038, 2038, 2040, 2043, 2044, 2045, 2052, 2065, 2074, 2074, 2073, 2072, 2072, 2073, 2075, 2076, 2079, 2082, 2087, 2092, 2097, 2102, 2106, 2111, 2115, 2118, 2122, 2126, 2133, 2143, 2154, 2165, 2175, 2184, 2191, 2195, 2194, 2187, 2175, 2161, 2144, 2126, 2108, 2091, 2077, 2065, 2056, 2049, 2042, 2037, 2034, 2032, 2030, 2028, 2027, 2026, 2027, 2028, 2029, 2029, 2029, 2029, 2029, 2030, 2031, 2032, 2031, 2031, 2032, 2034, 2035, 2036, 2036, 2036, 2037, 2038, 2039, 2040, 2040, 2041, 2043, 2044, 2045, 2045, 2044, 2044, 2045, 2046, 2047, 2048, 2049, 2049, 2049, 2049, 2048, 2046, 2044, 2043, 2042, 2043, 2043, 2043, 2044, 2044, 2045, 2047, 2049, 2052, 2054, 2056, 2057, 2058, 2057, 2056, 2054, 2052, 2050, 2048, 2047, 2045, 2044, 2044, 2044, 2043, 2042, 2025, 2016, 2016, 2074, 2205, 2279, 2279, 2237, 2129, 2055, 2047, 2047, 2048, 2048, 2046, 2044, 2044, 2050, 2061, 2070, 2077, 2081, 2083, 2085, 2086, 2086, 2087, 2089, 2092, 2095, 2097, 2099, 2103]";
    public static String dataSource = "[2071, 2086, 2099, 2109, 2144, 2003, 1937, 1937, 1954, 1970, 1972, 1972, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2057, 2066, 2074, 2081, 2089, 2097, 2105, 2113, 2122, 2132, 2143, 2154, 2164, 2117, 2124, 2130, 2134, 2136, 2138, 2139, 2141, 2143, 2145,1954, 1970, 1972, 1972, 2148, 2148, 2147, 2145, 2141, 2134, 2125, 1972, 1984, 2005, 2019, 2020, 2020, 2019, 2019, 2021, 2025, 2028, 2032, 2036, 2041, 2048, 2050]";
    /*预览*/
    private SurfaceView preview ;
    //预览设置信息
    private static SurfaceHolder previewHolder = null;
    /*相機對象*/
    private Camera camera ;

    public  int MAX = 150 ;

    public CameraHeartManager setMAX(int MAX) {
        this.MAX = MAX;
        return CameraHeartManager.this;
    }

    private static CameraHeartManager manager;

    public static CameraHeartManager newInstance(){
        if (null == manager) {
            synchronized (CameraHeartManager.class){
                if (null == manager){
                    manager = new CameraHeartManager();
                }
            }
        }
        return manager ;
    }



    /**
     * @param preview
     * @return
     */
    public CameraHeartManager setSurfaceView(SurfaceView preview) {
        this.preview = preview;
        return CameraHeartManager.this;
    }


    /**
     * 初始化
     */
    public void init(){
        if (preview!=null){
            camera = Camera.open();
            previewHolder = preview.getHolder();
            previewHolder.addCallback(surfaceCallback);
            previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }
    }


    /**
     * 设置摄像边上的led灯
     *
     * @param b
     * @return
     */
    public CameraHeartManager setLED(boolean b){
        if (camera!=null&&b){
            turnOn(camera.getParameters());
        }
        return CameraHeartManager.this;
    }


    /**
     *
     *
     * @param parameters
     */
    private void turnOn(Camera.Parameters parameters) {
        parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
        camera.setParameters(parameters);
    }




    /**
     * @param parameters
     */
    private void turnOff(Camera.Parameters parameters) {
        parameters.setFlashMode(parameters.FLASH_MODE_OFF);
        camera.setParameters(parameters);
    }




    /**
     * 开始预览
     */
    public void start(){
        if (preview!=null){
            if (camera==null) {
                /*这里一般是重新启动*/
                init();
            }
            /*开始预览*/
            camera.startPreview();
        }else {
            /*提示需要设置surfaceView*/
        }
    }




    /**
     * 停止释放
     */
    public void stop(){
        camera.setPreviewCallback(null);
        camera.stopPreview();
        camera.release();
        camera = null;
    }



    /**
     * 预览回调接口
     */
    private  SurfaceHolder.Callback surfaceCallback = new SurfaceHolder.Callback() {
        //创建时调用
        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            try {
                /*把预览的图像在surfview上展示出来*/
                camera.setPreviewDisplay(previewHolder);
                /*设置预览回调信息*/
                camera.setPreviewCallback(previewCallback);
            } catch (Throwable t) {
                Log.e("surfaceCallback","Exception in setPreviewDisplay()", t);
            }
        }



        //当预览改变的时候回调此方法
        @Override
        public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
            /*摄像头的参数*/
            Camera.Parameters parameters = camera.getParameters();
            /*摄像头旁边的LED灯*/
            parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
            /*获取最小的预览窗口*/
            Camera.Size size = getSmallestPreviewSize(width, height, parameters);
            if (size != null) {
                /*设置预览图片的大小*/
                parameters.setPreviewSize(size.width, size.height);
                //Log.d(TAG, "Using width=" + size.width + " height="	+ size.height);
            }
            /*将配置参数交给摄像头*/
            camera.setParameters(parameters);
            camera.setDisplayOrientation(90);
            camera.autoFocus(new Camera.AutoFocusCallback() {
                @Override
                public void onAutoFocus(boolean b, Camera camera) {

                }
            });
        }


        //销毁的时候调用
        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            // Ignore
        }
    };




    /**
     * 相机预览方法
     * 这个方法中实现动态更新界面UI的功能，
     * 通过获取手机摄像头的参数来实时动态计算平均像素值、脉冲数，从而实时动态计算心率值。
     */
    private  Camera.PreviewCallback previewCallback = new Camera.PreviewCallback() {

        public void onPreviewFrame(byte[] data, Camera cam) {
            if (data == null)
                throw new NullPointerException();
            Camera.Size size = cam.getParameters().getPreviewSize();
            if (size == null)
                throw new NullPointerException();
            if (!processing.compareAndSet(false, true))
                return;

            int width = size.width;
            int height = size.height;
            //图像处理  像素平均值
            int imgAvg = ImageProcessing.decodeYUV420SPtoRedAvg(data.clone(), height, width);
            if (imgAvg >= MAX){
                Log.i("=====imgAvg=====", "摄像头被挡住了"+imgAvg);
                if (addDrawHeartListener!=null){
                    addDrawHeartListener.onDraw();
                    addDrawHeartListener.onDown();
                }
            }else {
                Log.i("=====imgAvg=====", "摄像头正常"+imgAvg);
                if (addDrawHeartListener!=null)
                    addDrawHeartListener.onUp();
            }



            //            //像素平均值imgAvg,日志
//            Log.i("=====像素平均值imgAvg=====", "imgAvg=" + imgAvg);
//            if (imgAvg == 0 || imgAvg == 255) {
//                processing.set(false);
//                return;
//            }
//
//
//            //计算平均值
//            int averageArrayAvg = 0;
//            int averageArrayCnt = 0;
//            for (int i = 0; i < averageArray.length; i++) {
//                if (averageArray[i] > 0) {
//                    averageArrayAvg += averageArray[i];
//                    averageArrayCnt++;
//                }
//            }
//            //计算平均值
//            int rollingAverage = (averageArrayCnt > 0) ? ( averageArrayAvg / averageArrayCnt ) : 0;
//
//
//
//            TYPE newType = currentType;
//            if (imgAvg < rollingAverage) {
//                newType = TYPE.RED;
//                if (newType != currentType) {
//                    beats++;
//                }
//                Log.e("====beats====", "TYPE.RED脉冲数是!! beats=" + beats);
//            } else if (imgAvg > rollingAverage) {
//                newType = TYPE.GREEN;
//                Log.e("====beats====", "TYPE.GREEN脉冲数是!! beats=" + beats);
//            }
//
//
//            if (averageIndex == averageArraySize)
//                averageIndex = 0;
//
//
//            averageArray[averageIndex] = imgAvg;
//            averageIndex++;
//
//
//
//            // Transitioned from one state to another to the same
//            if (newType != currentType) {
//                currentType = newType;
//                //image.postInvalidate();
//            }
//
//
//            //获取系统结束时间（ms）
//            long endTime = System.currentTimeMillis();
//
//            double totalTimeInSecs = (endTime - startTime) / 1000d;
//
//            if (totalTimeInSecs >= 1) {
//
//                double bps = (beats / totalTimeInSecs);
//
//                int dpm = (int) (bps * 60d);
//
//                Log.v("===dpm====","beats="+beats+",dpm="+dpm);
//
//
//                if (dpm < 30 || dpm > 180 || imgAvg<200) {
//                    //获取系统开始时间（ms）
//                    startTime = System.currentTimeMillis();
//                    //beats心跳总数
//                    beats = 0;
//                    processing.set(false);
//                    return;
//                }
//
//
//                //Log.e(TAG, "totalTimeInSecs=" + totalTimeInSecs + " beats="+ beats);
//                if (beatsIndex == beatsArraySize)
//                    beatsIndex = 0;
//
//                beatsArray[beatsIndex] = dpm;
//                beatsIndex++;
//
//                int beatsArrayAvg = 0;
//                int beatsArrayCnt = 0;
//
//                for (int i = 0; i < beatsArray.length; i++) {
//                    if (beatsArray[i] > 0) {
//                        beatsArrayAvg += beatsArray[i];
//                        beatsArrayCnt++;
//                    }
//                }
//
//                int beatsAvg = (beatsArrayAvg / beatsArrayCnt);
//
//                String result =
//                        "心率是"+String.valueOf(beatsAvg)+
//                        "  zhi:"+String.valueOf(beatsArray.length) +
//                        "    "+String.valueOf(beatsIndex)+
//                        "    "+String.valueOf(beatsArrayAvg)+
//                        "    "+String.valueOf(beatsArrayCnt);
//
//                tv_Val.setText(result);
//
//                Log.v("====result=====","result="+result);
//                //获取系统时间（ms）
//                startTime = System.currentTimeMillis();
//                beats = 0;
//            }
            processing.set(false);
        }
    };



    AddDrawHeartListener addDrawHeartListener;

    public interface AddDrawHeartListener{
        void onDraw();
        void onDown();
        void onUp();
    }


    /**
     * 获取心率
     *
     * @return
     */
    public String getHeartRateVal(){
        ArrayList<String> list = StringToAscii.test(dataSource);
        Random random = new Random();
        int a = random.nextInt(list.size()-1);
        Log.i("=====imgAvg=====", "摄像头被挡住了="+a+"="+list.get(a));
        return list.get(a);
    }



    public CameraHeartManager addDrawHeartListener(AddDrawHeartListener addDrawHeartListener) {
        this.addDrawHeartListener=addDrawHeartListener;
        return CameraHeartManager.this;
    }


    /**
     * 获取相机最小的预览尺寸
     * @param width
     * @param height
     * @param parameters
     * @return
     */
    private Camera.Size getSmallestPreviewSize(int width, int height, Camera.Parameters parameters) {
        Camera.Size result = null;
        for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
            if (size.width <= width && size.height <= height) {
                if (result == null) {
                    result = size;
                } else {
                    int resultArea = result.width * result.height;
                    int newArea = size.width * size.height;
                    if (newArea < resultArea)
                        result = size;
                }
            }
        }
        return result;
    }



//    private static final int averageArraySize = 4;
//    private static final int[] averageArray = new int[averageArraySize];
//    //心跳下标值
//    private static int beatsIndex = 0;
//    //心跳数组的大小
//    private static final int beatsArraySize = 3;
//    //心跳数组
//    private static final int[] beatsArray = new int[beatsArraySize];
//    //心跳脉冲
//    private static double beats = 0;
//    private static int averageIndex = 0;
//
//    //开始时间
//    private static long startTime = 0;
//
//    /**
//     * 类型枚举
//     * @author liuyazhuang
//     *
//     */
//    public enum TYPE {
//        GREEN, RED
//    };
//    //设置默认类型
//    private static TYPE currentType = TYPE.GREEN;
//    //获取当前类型
//    public static TYPE getCurrent() {
//        return currentType;
//    }
}
